package com.gxa.controller.zijincontroller;

import com.gxa.common.R;
import com.gxa.pojo.*;
import com.gxa.service.zijinservice.FuKuanDanService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhaohaoc
 * @version 1.0
 * @date 2022/3/31 14:01
 */

@Controller
@Api(value = "资金付款模块test",tags = "资金付款模块API")
@RequestMapping("/ziJin/fuKuanDan")
@RequiresPermissions(value = {"付款单", "付款单记录"}, logical = Logical.OR)

public class FuKuanController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
    public FuKuanDanService fuKuanDanService;

    @ResponseBody
    @RequestMapping(value = "/insterFuKuanDan",method = RequestMethod.POST)
    @ApiOperation(value = "付款单添加接口",notes = "添加付款单信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "新增成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R insertFuKuanDan(@RequestBody FuKuanDan fuKuanDan){
        return fuKuanDanService.insertFuKuanDan(fuKuanDan);
    }

    @ResponseBody
    @RequestMapping(value = "/updateFuKuanDan",method = RequestMethod.POST)
    @ApiOperation(value = "付款单修改接口",notes = "修改付款单信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "修改成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R updateFuKuanDan(@RequestBody FuKuanDan fuKuanDan){
        return fuKuanDanService.updateFuKuanDan(fuKuanDan);
    }

    @ResponseBody
    @RequestMapping(value = "/delFuKuanDan",method = RequestMethod.POST)
    @ApiOperation(value = "付款单删除接口",notes = "删除付款单信息",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fuKuanDanBianHao", value = "单据编号", paramType = "query", dataType = "String",
                    required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "删除成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R delFuKuanDan( @ApiParam(name = "fuKuanDanBianHao",value = "单据编号",required = true)
                                       String fuKuanDanBianHao
    ){
       return fuKuanDanService.delFuKuanDan(fuKuanDanBianHao);
    }

    @ResponseBody
    @RequestMapping(value = "/selectFuKuanDan",method = RequestMethod.GET)
    @ApiOperation(value = "付款单查询接口",notes = "查询付款单信息",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "Date",
                    required = false),
            @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "Date",
                    required = false),
            @ApiImplicitParam(name = "fuKuanDanBianHao", value = "单据编号", paramType = "query", dataType = "String",
                    required = false),
            @ApiImplicitParam(name = "gongYingShangMingCheng", value = "供应商名称", paramType = "query", dataType = "String",
                    required = false),
            @ApiImplicitParam(name = "fuKuanDanBeiZhu", value = "收款备注", paramType = "query", dataType = "String",
                    required = false)
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectFuKuanDan(String startTime,String endTime,String fuKuanDanBianHao,
                             String gongYingShangMingCheng,String fuKuanDanBeiZhu){
        return fuKuanDanService.selectFuKuanDan(startTime,endTime,fuKuanDanBianHao,
                gongYingShangMingCheng,fuKuanDanBeiZhu);
    }

    @ResponseBody
    @RequestMapping(value = "/insertFuKuanDan/selectGongYingShang",method = RequestMethod.GET)
    @ApiOperation(value = "查询供应商信息接口",notes = "查询供应商",httpMethod = "get", response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectGongYingShang(){
        return fuKuanDanService.selectAllGongYingShang();
    }

    @ResponseBody
    @RequestMapping(value = "/insertFuKuanDan/selectGouHuoDan",method = RequestMethod.GET)
    @ApiOperation(value = "查询采购单信息接口",notes = "查询采购单",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始日期", paramType = "query", dataType = "Date",
                    required = false),
            @ApiImplicitParam(name = "endTime", value = "结束日期", paramType = "query", dataType = "Date",
                    required = false),
            @ApiImplicitParam(name = "gongYingShangMingCheng", value = "供应商名称", paramType = "query",
                    dataType = "String", required = true),
            @ApiImplicitParam(name = "danJuBianHao", value = "购货单编号", paramType = "query",
                    dataType = "String", required = false),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectGouHuoDan(String startTime,String endTime,
                             String gongYingShangMingCheng,String danJuBianHao){
        return fuKuanDanService.selectGouHuoDan(startTime,endTime,gongYingShangMingCheng,
                danJuBianHao);
    }

    @ResponseBody
    @RequestMapping(value = "/insertFuKuanDan/selectZhangHu",method = RequestMethod.GET)
    @ApiOperation(value = "查询收款结算账户信息接口",notes = "查询收款结算账户",httpMethod = "get", response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectFuKuanZhangHu(){
        return fuKuanDanService.selectAllZhangHu();
    }

    @ResponseBody
    @RequestMapping(value = "/insertFuKuanDan/selectJieSuanWay",method = RequestMethod.GET)
    @ApiOperation(value = "查询付款结算方式信息接口",notes = "查询付款结算方式",httpMethod = "get", response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectFuKuanJieSuanWay(){
        return fuKuanDanService.selectJieSuanWay();
    }
}
